<template>
<div>
<!--    <loginLogo/>-->
  <img src="../../static/img/background.jpg" class="background">
    <div class="signUp">
        <div class="signUp-head">
            <span>用户注册</span>
        </div>
        <el-form :model="registerParams" ref="registerForm" label-width="70px" class="demo-ruleForm" :rules="rules">
            <el-form-item prop="name" label="用户名">
                <el-input v-model="registerParams.name" placeholder="用户名"></el-input>
            </el-form-item>
            <el-form-item prop="password" label="密码">
                <el-input type="password" v-model="registerParams.password" placeholder="密码"></el-input>
            </el-form-item>
            <el-form-item prop="sex" label="性别">
                <el-radio-group v-model="registerParams.sex">
                    <el-radio :label="0">女</el-radio>
                    <el-radio :label="1">男</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item prop="phone" label="手机">
                <el-input v-model="registerParams.phone" placeholder="手机"></el-input>
            </el-form-item>
            <div class="login-btn">
                <el-button @click="goback(-1)">取消</el-button>
                <el-button type="primary" @click="SignUp">确定</el-button>
            </div>
        </el-form>
    </div>
</div>
</template>
<script>
import loginLogo from '../components/LoginLogo'
import {rules,cities} from '../assets/data/form'
import {mixin} from '../mixins'
import {Myregister} from "../api/user";

export default {
    name: 'sing-up',
    mixins: [mixin],
    components: {
        loginLogo
    },
    data() {
        return {
          registerParams: {
                name: '',       //用户名
                password: '',       //密码
                sex: 0,            //性别
                phone: '',       //手机
            },
            cities: [],            //所有的地区--省
            rules: {}               //表单提交的规则
        }
    },
    created() {
        this.rules = rules;
        this.cities = cities;
    },
    methods:{
        SignUp(){
          let _this = this;
          console.log(this.registerParams)
          Myregister(this.registerParams).then(res=>{
            if (res.data.code == 200){
              this.$message.success(res.data.message)
              this.$router.go(-1);
            }else {
              console.log("kdkkkkk")
              this.$message.error(res.data.message)
            }
          }).catch(error=>{
            this.$router.go(-1);
            // console.log("kdskfsdlk")
            // this.$message.error("用户注册失败")
          })
        },
        goback(index){
          // window.history.back();
          this.$router.go(-1);
        }
    }
}
</script>

<style lang="scss" scoped>
.background{
  width:100%;
  height: 100%;
  background: yellow;
  position: absolute;
}
.signUp{
  margin-top: 70px;
}
@import '../assets/css/sign-up.scss';
</style>
